--[[
FilePath: \Lua\View\UIActivityExplor\UIExplorGuide.lua
游园活动跳转
--]]

require 'View/UIBase/UIBase'

UIExplorGuide = UIBase.New(PanelNames.UIExplorGuide)
local _M = UIExplorGuide

_M.hasInit = false
_M.modelConfig = nil

function _M.Init(modelConfig)
    _M.modelConfig = modelConfig;
    UIBase.Init(_M)
end

function _M:OnCreate()
    if not _M.hasInit then
        self:RegisterOnClick(self:GetChild("Btn_BgClose"), self.OnBack)
        self.title = self:GetChild("Com_TwoBg"):GetChild("title");
        self.loaderCoin = self:GetChild("Loader_Coin");
        self.txtTips = self:GetChild("Text_GuideTips01");
        self.txtTips1 = self:GetChild("Text_GuideTips04");
        self.txtTips2 = self:GetChild("Text_GuideTips05");
        self.txtTips3 = self:GetChild("Text_GuideTips02");
        self.txtTips4 = self:GetChild("Text_GuideTips03");
        self.btnGo = self:GetChild("Btn_Go01");
        self.btnGo1 = self:GetChild("Btn_Go02");
        _M.hasInit = true;

        self:addEvent()
    end
end

function _M:addEvent()
    --self.btnHelp.onClick:Add(self.HelpTip, self)
    self.btnGo.onClick:Add(self.clickBtnGo, self);
    self.btnGo1.onClick:Add(self.clickBtnGo1, self);
end

function _M:removeEvent()
    --self.btnHelp.onClick:Remove(self.HelpTip)
    self.btnGo.onClick:Remove(self.clickBtnGo);
    self.btnGo1.onClick:Remove(self.clickBtnGo1);
end

function _M:HelpTip()
    if self.tableData ~= nil and self.tableData.f_ExplainTitle ~= nil and self.tableData.f_ExplainText ~= nil then
        logicMgr.UIShowManager.ShowCommonTips(tostring(self.tableData.f_ExplainTitle), tostring(self.tableData.f_ExplainText));
    end
end

function _M:clickBtnGo()
    if self.modelConfig ~= nil then
        showUI(PanelNames.UIExplorGift, nil, self.modelConfig.f_GiftActId);
    end
    closeUI(PanelNames.UIExplorGuide);
end

function _M:clickBtnGo1()
    closeUI(PanelNames.UIExplorGuide);
    closeUI(PanelNames.UIActivityExplor);
    closeUI(PanelNames.UIActivity);
    showUI(PanelNames.UIHeadMenu);
    logicMgr.FuncOpenManager.jump(206);
end

-- 显示
function _M:OnEnable()
    self:Refresh();
end

function _M:Refresh()
    if self.modelConfig ~= nil then
        self.loaderCoin.icon =  EnumConst.AtlasPath.ItemAtlas .. G.dataTable["t_item"][tostring(self.modelConfig.f_CostId)].f_Icon;
    end
    self.txtTips.text = getLanguage("ExplorGuideTips01");
    self.txtTips3.text = getLanguage("ExplorGuideTips02");
    self.txtTips4.text = getLanguage("ExplorGuideTips03");
    self.txtTips1.text = getLanguage("ExplorGuideTips04");
    self.txtTips2.text = getLanguage("ExplorGuideTips05");
    self.title.text = getLanguage("ActivityExplorTips04");
end

-- 隐藏
function _M:OnDisable()

end

-- 卸载
function _M:OnDestroy()
    self:removeEvent();
    self.hasInit = false
    self.modelConfig = nil;
end

return _M;